package com.mysimplenews.provider;

import com.mysimplenews.bean.ConfigXml;
import com.mysimplenews.bean.HomeApp;
import com.mysimplenews.bean.Lang;
import com.mysimplenews.news.NewsTabDao;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by cxy on 2016/6/14.
 */
public class TabsProvider {

    private NewsTabDao newsTabDao;

    public TabsProvider(){
        newsTabDao = new NewsTabDao();
    }

    public List<String> getTabs(String response){
        ConfigXml tabData = newsTabDao.getTabData(response);
        List<String> tabs = new ArrayList<String>();
        List<HomeApp> homeApps = tabData.getHomeApps();
        for (int i = 0; i < homeApps.size(); i++) {
            HomeApp homeApp = homeApps.get(i);
            for (Lang lang : homeApp.getValue().getLangs()) {
                if("cn".equalsIgnoreCase(lang.getI18n())){
                    tabs.add(lang.getTitle());
                }
            }
        }
        return tabs;
    }
}
